var myDate = new Date();
var year = myDate.getFullYear();   //获取完整的年份(4位,1970-????)
var month =myDate.getMonth()+1;      //获取当前月份(0-11,0代表1月)
var day = myDate.getDate();       //获取当前日(1-31)
if(month<10)month="0"+month;
if(day<10)day="0"+day;
var tody = year+"-"+month+"-"+day;

//取得资产详细信息
var GET_T_FIXED_ASSETS_DETAIL = function(){
	var BARCODE = $("input[name='check'][checked]").val(); 
	if(BARCODE==undefined){alert("请选择资产!");return;}
	
	var url = cw.common.path + '/json?action=GET_T_FIXED_ASSETS_DETAIL_ACTION&ID='+BARCODE;
	$.post(url,{},function(data){
		if(data.success){
			var vobj=data.root.T_FIXED_ASSETS_DETAIL;
			if(vobj==null||vobj==''||vobj==undefined){
				alert("该资产不存在或已被删除");
				return;
			}
			else{
				var obj = data.root.T_FIXED_ASSETS_DETAIL.rs[0];
				$("#ID").val(obj.ID);
				$("#BARCODE").val(obj.BARCODE);
				$("#BEFOR_PRICE").val(obj.STOCK_PRICE);
				cw.common.getValue('BEFOR_PRICE_TEXT',obj.BEFOR_PRICE,'0.0');
				cw.common.getValue('BARCODE_TEXT',obj.BARCODE,'');
				cw.common.getValue('STOCK_PRICE',obj.STOCK_PRICE,'');
				cw.common.getValue('DEPARTMENT_NAME',obj.DEPARTMENT_NO_NAME,'');
				cw.common.getValue('STOCK_DATE',obj.STOCK_DATE,'');
				cw.common.getValue('USE_YEAR',obj.USE_YEAR,'');
				cw.common.getValue('WARRANTY',obj.WARRANTY,'');
				cw.common.getValue('SPECIFICATION',obj.SPECIFICATION,'');
				cw.common.getValue('SUPPLIERS_NAME',obj.DEPARTMENT_NO_NAME,'');
				cw.common.getValue('FACTORY_NO',obj.FACTORY_NO,'');
				cw.common.getValue('STORED_IN',obj.STORED_IN,'');
				cw.common.getValue('WITH_MANANGER_NAME',obj.WITH_MANANGER_NAME,'');
				cw.common.getValue('REMARK_TEXT',obj.REMARK,'');
				$("#floatBox").hide();
				$("#floatBoxBg").hide();
				$('#subImg').bind('click',subButton);
			}
		}
		else{
			alert(data.errors.errmsg);
		}
	},'json');
}
//查询人员
var queryPERSONNAL = function(){
	$.post(cw.common.path+'/json',
			{
				action : 'QUERY_T_PERSONNAL_ACTION'
			}, function(data){
				if (data.success) {
					var length = data.root.T_PERSONNAL.rs.length;
					if(length > 0){
						for(var i=0;i<length;i++) {
							var obj=data.root.T_PERSONNAL.rs[i];
							$("#PERSON").append("<option value='"+obj.PERSONNAL_NO+"'>"+obj.NAME+"</option>");
						}
						//getGSDEMT();
					}
				} else {
					alert(data.errors.errmsg);
				}
			}, 'json');
}
//查询归属部门
var getGSDEMT = function(){
	var pid = $("#PERSON").val();
	$.post(cw.common.path+'/json',
			{
				action : 'GET_T_PERSONNAL_ACTION',
				PERSONNAL_NO:pid
			}, function(data){
				if (data.success) {
					var length = data.root.T_PERSONNAL.rs.length;
					if(length > 0){
						
						var obj=data.root.T_PERSONNAL.rs[0];
						$("#PERSON_DEMT").html(obj.DEPARTMENT_NO_NAME);
					}
				} else {
					alert(data.errors.errmsg);
				}
			}, 'json');
}

//显示资产信息
function showDialog(){
	var content = '';
	content += '<div style="text-align:center;border:1px dotted;background:#999999;padding: 5px; margin-bottom:10px;">';
		content += '<table width="100%" align="center">';
			content += '<tr><td valign="top"><span id="loadDiv">数据载入中...</span></td></tr>';
			content += '<tr><td valign="top">';
				content += '<div>';
					content += '<ul class="list">';
						content += '<li>';
							content += '<em style="float:right;">';
							content += '条形码：<input type="text" name="BARCODE_SE" id="BARCODE_SE" style="width: 80px"/>&nbsp;&nbsp;&nbsp;&nbsp;';
							content += '资产名称：<input type="text" name="FIXED_ASSETS_NAME" id="FIXED_ASSETS_NAME" style="width: 80px"/>&nbsp;&nbsp;&nbsp;&nbsp;';
							content += '<input type="button" class="btn_common" value="查询" onclick="cw.common.getUserSession(loadT_FIXED_ASSETS_DETAIL);"/>';
							content += '</em>';
						content += '</li>';
					content += '</ul>';
				content += '</div>';
			content += '</td></tr>';
			
			content += '<tr><td valign="top">';
				content += '<div id="T_FIXED_ASSETS_DETAILLIST">';
				
					content += '<div>';
						content += '<ul class="list_tit">';
							content += '<li class="fB">';
								content += '<em style="width: 8%; text-align: center;">选择</em>';
								content += '<em style="width: 12%; text-align: center;">条形码</em>';
								content += '<em style="width: 20%; text-align: center;">资产名称</em>';
								content += '<em style="width: 20%; text-align: center;">规格</em>';
								content += '<em style="width: 20%; text-align: center;">厂家</em>';
								content += '<em style="width: 20%; text-align: center;">出厂编号</em>';
							content += '</li>';
						content += '</ul>';
					content += '</div>';
					
					content += '<div>';
						content += '<ul id="T_FIXED_ASSETS_DETAIL_LIST" class="list">';
						content += '</ul>';
					content += '</div>';
					content += '<div style="clear: both"></div>';
						content += '<div>';
							content += '<div style="padding-left:24px; padding-top:5px;">';
								content += '<span id="T_FIXED_ASSETS_DETAIL_pager" class="tnt_pagination"></span>';
							content += '</div>';
						content += '</div>';
					content += '</div>';
			content += '</div></td></tr>';
	content += '</table><div align="center" style="padding-top:5px;">';
	content += '<input type="button" id="stb" value="选择" style="display:none" onclick="GET_T_FIXED_ASSETS_DETAIL();"/>';
	content+='</div>';
	content+='<iframe style="position:absolute;z-index:-1;width:700;height:400;top:0;left:0" frameborder="0"></iframe>';
	content+='</div>';
	dialog("资产详细信息","text:"+content,"700px","auto","floatPoint");
	setTimeout('loadT_FIXED_ASSETS_DETAIL()',1000);
	$("#loadDiv").hide();
	$('#stb').show();
}

//载入资产详细信息
function loadT_FIXED_ASSETS_DETAIL(){
	var BARCODE=$("#BARCODE_SE").val();
	var FA_STATUS=$("#FA_STATUS").val();
	var FIXED_ASSETS_NAME = $("#FIXED_ASSETS_NAME").val();
	var url = cw.common.path + '/json?action=QUERY_T_FIXED_ASSETS_DETAILBY_PAGER_ACTION';
	url += "&BARCODE="+BARCODE+"&FA_STATUS="+FA_STATUS+"&FIXED_ASSETS_NAME="+FIXED_ASSETS_NAME;
	var xmlname = "T_FIXED_ASSETS_DETAIL";
	var pagePanel='#T_FIXED_ASSETS_DETAIL_pager';
	var result='#T_FIXED_ASSETS_DETAIL_LIST';
	var pageSize=6;
	var defaultHtml='<li><em style="text-align: center;width:100%">没有搜索到您要查询的数据...</em></li>';
	cw.common.changePage(url,pageSize,xmlname,result,fn_queryT_FIXED_ASSETS_DETAILLIST,pagePanel,defaultHtml);
}
var fn_queryT_FIXED_ASSETS_DETAILLIST = function(obj,result,i){
	var str='<li id="bar_'+obj.ID+'">';
	str+='<em style="width: 8%; text-align: center;"><input type="radio" name="check" value="'+obj.ID+'" /></em>';
	str+='<em style="width: 12%; text-align: center;">'+obj.BARCODE+'</em>';
	str+='<em style="width: 20%; text-align: center;">'+obj.FIXED_ASSETS_NAME+'</em>';
	str+='<em style="width: 20%; text-align: center;">'+obj.SPECIFICATION+'</em>';
	str+='<em style="width: 20%; text-align: center;">'+obj.SUPPLIERS_NO_NAME+'</em>';
	str+='<em style="width: 20%; text-align: center;">'+obj.FACTORY_NO+'</em>';
	str+='</li>';
	$(result).append(str);
}